<%@page import="org.proddevplm.dao.data.Roles"%>
<%@page import="org.proddevplm.dao.data.Project"%>
<%@page import="org.proddevplm.dao.data.RelationMatrix"%>
<%@page import="java.util.List"%>
<script type="text/javascript">

	$(function(){
		$( "button" ).button();
		$("#homeButtonset").buttonset();
	});
	
	function loadHomePage(page){
		$("#selectHomeTabPage").load(page);
	}
	
	function loadHomePageWithReq(request, page){
		$.post(request, function(data) {
            $("#selectHomeTabPage").load(page);
        });
	}
	
	function newProduct(){
		loadHomePage("content/project/home/newProduct.jsp");
	}
	
	function editProject(){
		loadHomePage("content/project/home/editProject.jsp");
	}
	
	function openOtherProject(){
		loadHomePageWithReq("/proddev/controller?manager=flowManager&method=1","content/project/openProject.jsp");
	}
	
	newProduct();
		
</script>

<%
	String currentRole = "";
	List relMatrixUser = (List)session.getAttribute("relMatrixUser");
	int projectId = (Integer)session.getAttribute("projectId");
	for (int index=0; index<relMatrixUser.size(); index++){
		RelationMatrix rm = (RelationMatrix)relMatrixUser.get(index);
		Project userProject = rm.getProject();
		if(userProject.getId()==projectId){
			Roles userRole = rm.getRole();
			currentRole = userRole.getRole();
		}
	}

%>

<div style="width:auto;">
	
	<div id="homeButtonset" style="width:100%;">
		<input type="radio" name="radio" id="newProduct" checked="checked" onclick="newProduct()"/><label for="newProduct"><b>New product</b></label>
		<%if(currentRole.equals("Project Manager")) {%>
			<input type="radio" name="radio" id="editProject" onclick="editProject()"/><label for="editProject"><b>Edit project</b></label>
		<%} %>
		<input type="radio" name="radio" id="openOtherProject" onclick="openOtherProject()"/><label for="openOtherProject"><b>Open other project</b></label>			
	</div>
		
	<div style="width:100%; float:left;">
	
		<jsp:include page="/pages/content/project/home/selectionPage.jsp"></jsp:include>
	
	</div>
	<div style="clear:both"></div>


</div>